clear all
load ParEst_eh0_time0_Mex_nokids ParEst_eh0_time0_Mex_nokids
load trans_time1_eh0_comp0.out
Chute=ParEst_eh0_time0_Mex_nokids;
%Chute =[ParEst_eh0_time0_Mex_nokids, ParEst_eh0_time0_Mex_nokids(22),ParEst_eh0_time0_Mex_nokids(23), ParEst_eh0_time0_Mex_nokids(24)];
HandleLo = @Principal_A2_n;
Dij=trans_time1_eh0_comp0(1,:)'; % Read transition moments

Dnf_1	 =	Dij(1);
Dni_1	 =	Dij(2);
Dfn_1	 =	Dij(3);
Dff_1	 =	0;
Dfi_1	 =	Dij(4);
Din_1	 =	Dij(5);
Dii_1	 =	0;
Dif_1  =	Dij(6);
Dni_df_1 = Dij(7);    % Transitions for spouse 2 (spouse) from not working to informal when spouse 1 (head) loses job in formal sector
Dni_di_1 = Dij(8);    % Transitions for spouse 2 (spouse) from not working to informal when spouse 1 (head) loses job in informal sector
Dnf_2	 =	Dij(9);
Dni_2	 =	Dij(10);
Dfn_2	 =	Dij(11);
Dff_2	 =	0;
Dfi_2	 =	Dij(12);
Din_2	 =	Dij(13);
Dii_2	 =	0;
Dif_2  =	Dij(14);
Dni_df_2 = Dij(15);
Dni_di_2 = Dij(16);
Lower =[Dfn_1,Din_1,Dnf_1,Dni_1,Dfi_1,Dif_1,Dfn_2,Din_2,...
     Dnf_2,Dni_2,Dfi_2,Dif_2,Dni_df_2,Dni_di_2,Dni_df_1,Dni_di_1];
LoBo =zeros(1,29);
LoBo = [Lower, 0.1, 0.1, 0.1, 0.1, -10, -2, -10, -10, -2, -10, -10, 0, 0];
HiBo = [.81 .81 .81 .991 .81 .81 .81 .81 .81 .81 .81 .81 .91 .81 .91 .91 10 10 10 10 -4 2 0 0 2 0 0 1 1];
%options = optimoptions(@simulannealbnd, ...
 %                    'PlotFcn',{@saplotbestf,@saplottemperature,@saplotf,@saplotbestx,@saplotx},...
  %                    'FunctionTolerance',800,'ReannealInterval',2, ...
   %                  'InitialTemperature', 2*10^4*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 10 10 10 60], ...
    %                 'TemperatureFcn', @temperaturefast, 'MaxStallIterations', 4000);
                 options = saoptimset( ...
                     'TolFun',4000,'ReannealInterval',4, ...
                     'InitialTemperature', 10^2*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 10 10 6 4 10 10 4 10 10 1 1], ...
                     'TemperatureFcn', @temperaturefast, 'TimeLimit', 3*86400); % temp default 16*10^2* 
[x,fval,exitflag,output]  = simulannealbnd(HandleLo, Chute, LoBo, HiBo, options)
ParEst_eh0_time0_Mex_nokids = x;
save ParEst_eh0_time0_Mex_nokids ParEst_eh0_time0_Mex_nokids
